(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
var { Point } = require("./Point.js");

// var k1 = 1
class Plot {
  static viewv = {
    left: 0,
    top: 0,
    k1: 1
  };
  /**
   * Creates an instance of Plot.
   * 画布，所有被画出来的元素都append到这个container
   * @memberof Plot
   * @param canvasDom {HTMLCanvasElement}
   */
  constructor(canvasDom) {

    /**
     * @type {HTMLCanvasElement}
     */
    this.container = canvasDom; //
    canvasDom.width = document.body.clientWidth;
    canvasDom.height = document.body.clientHeight;
    //  初始化长宽
    canvasDom.style.width = document.body.clientWidth + "px";
    canvasDom.style.height = document.body.clientHeight + "px";
    this.context = this.container.getContext("2d");
    //原点
    this.radius = 2; // 点的半径
    /**
     * @type {Point}
     */
    this.origin = new Point(0, 0);
    // this.context.setTransform

    this.context.translate(this.container.width / 2, this.container.height / 2);
    this.context.rotate(Math.PI * 1.5);
    //坐标颜色
    this.baseLineColor = "black";
    //画笔颜色
    this.brushColor = "red";
    //画笔粗细

    this.gain = 1;
    // this.drawCoordinate();
    this.initKeyEvent();
    this.points = [];
    this.lines = [];
    this.clean()
    //baseLineX，baseLineY保存坐标线，用于坐标移位
    //初始化方法，设置画布，原点位置，坐标线颜色，画笔颜色，画笔粗细
    //  var rect = canvas.getBoundingClientRect();
  }

  init(baseLineColor, brushColor) {
    this.baseLineColor = baseLineColor;
    this.brushColor = brushColor;
    this.drawCoordinate();
  }
  /**
   * 原点
   * @param {any} p
   * @memberof Plot
   */
  setOPoint(p) {
    if (p.x != undefined && p.y != undefined) this.origin = p;
    this.context.translate(
      this.container.width / 2 + p.x,
      this.container.height / 2 + p.y
    );
    this.drawCoordinate();
  }
  //画坐标线
  drawCoordinate() {
    var height = this.container.height;
    var width = this.container.width;
    this.line(
      { x: 0, y: -height / 2 }, //this.container.width / 2
      { x: 0, y: height / 2 }
    );
    this.line({ x: -width, y: 0 }, { x: width, y: 0 });
  }
  //清理画布，移走所有对象
  clean() {
    // this.context.fillStyle = "#000000";
    // this.context.beginPath(); 
    // this.container.width/2
    // this.context.fillRect(-Infinity, -Infinity, Infinity, Infinity);
    // this.context.closePath();
    // console.log(-this.container.width / 2, -this.container.height / 2, 2 * this.container.width, 2 * this.container.height)
    // this.context.clearRect(-this.container.width / 2, -this.container.height / 2, 2 * this.container.width, 2 * this.container.height);
    // this.drawCoordinate();
    this.fillColor([0, 1, 0, 255])
  }
  
  fillColor(color4) {
    var { context } = this;
    let { width: w, height: h } = this.container
    var a = context.getImageData(0, 0, w, h)
    var data = a.data
    var [cr, cg, cb, ca] = color4
    for (let index = 0, len = data.length; index < len;) {
      data[index++] = cr
      data[index++] = cg
      data[index++] = cb
      data[index++] = ca
    }
    context.putImageData(a, 0, 0);
  }

  drawColor(cb) {
    var { context } = this;
    let { width: w, height: h } = this.container
    var a = context.getImageData(0, 0, w, h)
    context.putImageData(a, 0, 0);
  }
  
  /**
   * // 画点，相对原点  //div 绘制点 
   * @param {*} p 
   * @param {*} color 
   */
  drawDot(p, color) {
    if (!(p.x != undefined && p.y != undefined))
      return; //校验
    this.context.beginPath();
    this.context.arc(p.y, p.x, this.radius, 0, Math.PI * 2, false); //x ,y r ,stangle
    this.context.closePath();
    this.context.fillStyle = color || this.brushColor;
    //本来这里最初使用的是red，
    this.context.fill();
  }
  /**
   * 
   *   //画线从(x0,y0)到(x1,y1)
   * @param {*} point0 
   * @param {*} point1 
   * @param {string} color 
   */
  line(point0, point1, color = "red") {
    //竖线
    this.context.lineWidth = this.radius / 2;
    this.context.save();
    this.context.beginPath();
    this.context.moveTo(point0.y, point0.x); //将画笔移到x0,y0处//point0.x,
    this.context.lineTo(point1.y, point1.x); //从x1,y1到x2,y2画条线
    this.context.strokeStyle = color;
    this.context.stroke(); //画线
    this.context.restore();
  }
  drawPoint(p, color) {
    this.points.push([p, color]);
    this.drawDot(p, color)
  }
  drawNodeSet(nodes, color = "red") {
    //绘制节点集合
    // if (nodes) 
    // this.points = this.points.concat(nodes);
    for (var index in nodes) {
      this.drawDot(nodes[index], color);
    }
  }
  drawLine(point0, point1) {
    this.lines.push([point0, point1]);
    this.line(point0, point1);
  }
  reDraw() {
    this.points.forEach((params) => {
      this.drawDot.apply(this, params)
    });
    this.lines.forEach((params) => {
      this.line.apply(this, params)
    })
  }

  initKeyEvent() {
    let movd = 5;
    
    console.log(" // 38 40 |37 39 // 上下 左右  [] 放大缩小")
    document.addEventListener("keydown", e => {
      var viewv = Plot.viewv
      //this.origin.y -= movd * k1;
      var centerX = viewv.left + this.container.width / 2 * viewv.k1;
      var centerY = viewv.top + this.container.height / 2 * viewv.k1;
      switch (e.which) {
        case 38:
          this.context.translate(-movd * viewv.k1, 0);
          viewv.top -= movd * viewv.k1;
          break;
        case 40:
          this.context.translate(movd *viewv. k1, 0);
          viewv.top += movd * viewv.k1;
          break;
        case 37:
          this.context.translate(0, -movd *viewv. k1);
          viewv.left -= movd * viewv.k1;
          break;
        case 39:
          this.context.translate(0, movd * viewv.k1);
          viewv.left += movd * viewv.k1;
          break;
        case 221:
          this.context.scale(0.8, 0.8);
          this.radius /= 0.8
          viewv. k1 *= 0.8;
          viewv.top = centerY - viewv.k1 * this.container.height / 2;
          viewv.left = centerX - viewv.k1 * this.container.width / 2;
          break;
        case 219:
          this.context.scale(1 / 0.8, 1 / 0.8);
          this.radius *= 0.8
          viewv.k1 *= 1.25;
          viewv.top = centerY - viewv.k1 * this.container.height / 2;
          viewv.left = centerX - viewv.k1 * this.container.width / 2;
          break;
      }

      this.clean();
      this.reDraw();
    });
  }
  /**
   * @param {{x:number,y:number}[]} list
   */
  drawList(list) {
    var viewv = Plot.viewv
    var k1 = viewv.k1
    var a, p
    this.COLOR = 255
    var { context, COLOR } = this;
    context.shadowColor = "#000"
    let { width: w, height: h } = this.container
    let b = (a = context.getImageData(0, 0, w, h)).data; // let
    for (let index = 0, len = b.length; index < len;) {
      b[index++] = 0
      b[index++] = 0
      b[index++] = 0
      b[index++] = 255
    }
    let dlen = b.length;
    for (let i = 0, len = list.length; i < len; i++) {
      p = list[i];
      let x13 = (p.x - viewv.left) / k1;
      let y13 = (p.y - viewv.top) / k1;
      if (x13 < 0 || x13 >= w || y13 < 0 || y13 >= h) continue;
      let n = ~~(x13 + ~~y13 * w) * 4;
      if (n < 0 || n >= dlen - 3) {
        continue;
      }
      // @ts-ignore
      b[n] = b[n + 1] = b[n + 2] = p.COLOR || COLOR, b[n + 3] = 255
    }
    context.putImageData(a, 0, 0);
  }
  
  /**
   * 
   * @param {number[]} color 
   */
  pickColor(color, diff = 1) {
    var data = this.context.getImageData(0, 0, this.container.width, this.container.height).data;
    var list = [];
    var { k1, left, top } = Plot.viewv
    var w = this.container.width;
    for (let index = 0, len = data.length; index < len; index += 4) {
      var w0 = (index / 4) % w;
      var h0 = ((index / 4) - w0) / w;
      // && data[index + 1] == color[1] && data[index + 2] == color[2] && data[index + 3] == color[3]
      // todo
      if (Math.abs(data[index] - color[0]) <= diff
        && Math.abs(data[index + 1] - color[1]) <= diff
        && Math.abs(data[index + 2] - color[2]) <= diff
        && Math.abs(data[index + 3] - color[3]) <= diff
      ) {
        list.push({ x: w0 * k1 + left, y: h0 * k1 + top })
      }
    }
    return list
  }
  get center() {
    var { k1, left, top } = Plot.viewv
    return { x: this.container.width / 2 * k1 + left, y: this.container.height * k1 + left }
  }
}
module.exports = { Plot };

},{"./Point.js":2}],2:[function(require,module,exports){
class Point {
  /** @type {Number} */
  vx;
  /** @type {Number} */
  vy;

  /**
   *  x,y构造
   * @param {Number} x
   * @param {Number} y
   */
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }
  /**
   *  欧式距离
   * @param {Point} point1
   * @param {Point} point2
   */
  static len(point1, point2) {

    var len = Math.sqrt((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y)
    );
    len = Math.max(len, 1e-7)
    return len;
  }

  /**
   * 
   * @param {{x:number,y:number}[]} ps 
   */
  static countCenter(ps) {
    var sumx = 0, sumy = 0;
    ps.forEach(v => {
      sumx += v.x;
      sumy += v.y;
    })
    return { x: sumx / ps.length, y: sumy / ps.length }
  }
  /**
   * 检查对象格式
   * @param {Point} obj
   */
  static check(obj) {
    return obj && obj.x && obj.y;
  }

  /**
   * 
   * @param {Point[]} points 
   */
  static sumV(points) {
    var sv = 0;
    for (let index = 0, len = points.length; index < len; index++) {
      // const element = points[index];
      sv += (points[index].vx ** 2 + points[index].vy ** 2) ** 0.5
    }
    return sv;
  }
}
module.exports = { Point }

},{}],3:[function(require,module,exports){
// Pressure v2.1.2 | Created By Stuart Yamartino | MIT License | 2015 - 2017
;(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], factory);
  } else if (typeof exports === 'object') {
    module.exports = factory();
  } else {
    root.Pressure = factory();
  }
}(this, function() {
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

//--------------------- Public API Section ---------------------//
// this is the Pressure Object, this is the only object that is accessible to the end user
// only the methods in this object can be called, making it the "public api"

var Pressure = {

  // targets any device with Force or 3D Touch
  set: function set(selector, closure, options) {
    loopPressureElements(selector, closure, options);
  },


  // set configuration options for global config
  config: function config(options) {
    Config.set(options);
  },


  // the map method allows for interpolating a value from one range of values to another
  // example from the Arduino documentation: https://www.arduino.cc/en/Reference/Map
  map: function map(x, in_min, in_max, out_min, out_max) {
    return _map.apply(null, arguments);
  }
};

var Element = function () {
  function Element(el, block, options) {
    _classCallCheck(this, Element);

    this.routeEvents(el, block, options);
    this.preventSelect(el, options);
  }

  _createClass(Element, [{
    key: 'routeEvents',
    value: function routeEvents(el, block, options) {
      var type = Config.get('only', options);
      // for devices that support pointer events
      if (supportsPointer && (type === 'pointer' || type === null)) {
        this.adapter = new AdapterPointer(el, block, options).bindEvents();
      }
      // for devices that support 3D Touch
      else if (supportsTouch && (type === 'touch' || type === null)) {
          this.adapter = new Adapter3DTouch(el, block, options).bindEvents();
        }
        // for devices that support Force Touch
        else if (supportsMouse && (type === 'mouse' || type === null)) {
            this.adapter = new AdapterForceTouch(el, block, options).bindEvents();
          }
          // unsupported if it is requesting a type and your browser is of other type
          else {
              this.adapter = new Adapter(el, block).bindUnsupportedEvent();
            }
    }

    // prevent the default action of text selection, "peak & pop", and force touch special feature

  }, {
    key: 'preventSelect',
    value: function preventSelect(el, options) {
      if (Config.get('preventSelect', options)) {
        el.style.webkitTouchCallout = "none";
        el.style.webkitUserSelect = "none";
        el.style.khtmlUserSelect = "none";
        el.style.MozUserSelect = "none";
        el.style.msUserSelect = "none";
        el.style.userSelect = "none";
      }
    }
  }]);

  return Element;
}();

/*
This is the base adapter from which all the other adapters extend.
*/

var Adapter = function () {
  function Adapter(el, block, options) {
    _classCallCheck(this, Adapter);

    this.el = el;
    this.block = block;
    this.options = options;
    this.pressed = false;
    this.deepPressed = false;
    this.nativeSupport = false;
    this.runningPolyfill = false;
    this.runKey = Math.random();
  }

  _createClass(Adapter, [{
    key: 'setPressed',
    value: function setPressed(boolean) {
      this.pressed = boolean;
    }
  }, {
    key: 'setDeepPressed',
    value: function setDeepPressed(boolean) {
      this.deepPressed = boolean;
    }
  }, {
    key: 'isPressed',
    value: function isPressed() {
      return this.pressed;
    }
  }, {
    key: 'isDeepPressed',
    value: function isDeepPressed() {
      return this.deepPressed;
    }
  }, {
    key: 'add',
    value: function add(event, set) {
      this.el.addEventListener(event, set, false);
    }
  }, {
    key: 'runClosure',
    value: function runClosure(method) {
      if (method in this.block) {
        // call the closure method and apply nth arguments if they exist
        this.block[method].apply(this.el, Array.prototype.slice.call(arguments, 1));
      }
    }
  }, {
    key: 'fail',
    value: function fail(event, runKey) {
      if (Config.get('polyfill', this.options)) {
        if (this.runKey === runKey) {
          this.runPolyfill(event);
        }
      } else {
        this.runClosure('unsupported', event);
      }
    }
  }, {
    key: 'bindUnsupportedEvent',
    value: function bindUnsupportedEvent() {
      var _this = this;

      this.add(supportsTouch ? 'touchstart' : 'mousedown', function (event) {
        return _this.runClosure('unsupported', event);
      });
    }
  }, {
    key: '_startPress',
    value: function _startPress(event) {
      if (this.isPressed() === false) {
        this.runningPolyfill = false;
        this.setPressed(true);
        this.runClosure('start', event);
      }
    }
  }, {
    key: '_startDeepPress',
    value: function _startDeepPress(event) {
      if (this.isPressed() && this.isDeepPressed() === false) {
        this.setDeepPressed(true);
        this.runClosure('startDeepPress', event);
      }
    }
  }, {
    key: '_changePress',
    value: function _changePress(force, event) {
      this.nativeSupport = true;
      this.runClosure('change', force, event);
    }
  }, {
    key: '_endDeepPress',
    value: function _endDeepPress() {
      if (this.isPressed() && this.isDeepPressed()) {
        this.setDeepPressed(false);
        this.runClosure('endDeepPress');
      }
    }
  }, {
    key: '_endPress',
    value: function _endPress() {
      if (this.runningPolyfill === false) {
        if (this.isPressed()) {
          this._endDeepPress();
          this.setPressed(false);
          this.runClosure('end');
        }
        this.runKey = Math.random();
        this.nativeSupport = false;
      } else {
        this.setPressed(false);
      }
    }
  }, {
    key: 'deepPress',
    value: function deepPress(force, event) {
      force >= 0.5 ? this._startDeepPress(event) : this._endDeepPress();
    }
  }, {
    key: 'runPolyfill',
    value: function runPolyfill(event) {
      this.increment = Config.get('polyfillSpeedUp', this.options) === 0 ? 1 : 10 / Config.get('polyfillSpeedUp', this.options);
      this.decrement = Config.get('polyfillSpeedDown', this.options) === 0 ? 1 : 10 / Config.get('polyfillSpeedDown', this.options);
      this.setPressed(true);
      this.runClosure('start', event);
      if (this.runningPolyfill === false) {
        this.loopPolyfillForce(0, event);
      }
    }
  }, {
    key: 'loopPolyfillForce',
    value: function loopPolyfillForce(force, event) {
      if (this.nativeSupport === false) {
        if (this.isPressed()) {
          this.runningPolyfill = true;
          force = force + this.increment > 1 ? 1 : force + this.increment;
          this.runClosure('change', force, event);
          this.deepPress(force, event);
          setTimeout(this.loopPolyfillForce.bind(this, force, event), 10);
        } else {
          force = force - this.decrement < 0 ? 0 : force - this.decrement;
          if (force < 0.5 && this.isDeepPressed()) {
            this.setDeepPressed(false);
            this.runClosure('endDeepPress');
          }
          if (force === 0) {
            this.runningPolyfill = false;
            this.setPressed(true);
            this._endPress();
          } else {
            this.runClosure('change', force, event);
            this.deepPress(force, event);
            setTimeout(this.loopPolyfillForce.bind(this, force, event), 10);
          }
        }
      }
    }
  }]);

  return Adapter;
}();

/*
This adapter is for Macs with Force Touch trackpads.
*/

var AdapterForceTouch = function (_Adapter) {
  _inherits(AdapterForceTouch, _Adapter);

  function AdapterForceTouch(el, block, options) {
    _classCallCheck(this, AdapterForceTouch);

    return _possibleConstructorReturn(this, (AdapterForceTouch.__proto__ || Object.getPrototypeOf(AdapterForceTouch)).call(this, el, block, options));
  }

  _createClass(AdapterForceTouch, [{
    key: 'bindEvents',
    value: function bindEvents() {
      this.add('webkitmouseforcewillbegin', this._startPress.bind(this));
      this.add('mousedown', this.support.bind(this));
      this.add('webkitmouseforcechanged', this.change.bind(this));
      this.add('webkitmouseforcedown', this._startDeepPress.bind(this));
      this.add('webkitmouseforceup', this._endDeepPress.bind(this));
      this.add('mouseleave', this._endPress.bind(this));
      this.add('mouseup', this._endPress.bind(this));
    }
  }, {
    key: 'support',
    value: function support(event) {
      if (this.isPressed() === false) {
        this.fail(event, this.runKey);
      }
    }
  }, {
    key: 'change',
    value: function change(event) {
      if (this.isPressed() && event.webkitForce > 0) {
        this._changePress(this.normalizeForce(event.webkitForce), event);
      }
    }

    // make the force the standard 0 to 1 scale and not the 1 to 3 scale

  }, {
    key: 'normalizeForce',
    value: function normalizeForce(force) {
      return this.reachOne(_map(force, 1, 3, 0, 1));
    }

    // if the force value is above 0.995 set the force to 1

  }, {
    key: 'reachOne',
    value: function reachOne(force) {
      return force > 0.995 ? 1 : force;
    }
  }]);

  return AdapterForceTouch;
}(Adapter);

/*
This adapter is more mobile devices that support 3D Touch.
*/

var Adapter3DTouch = function (_Adapter2) {
  _inherits(Adapter3DTouch, _Adapter2);

  function Adapter3DTouch(el, block, options) {
    _classCallCheck(this, Adapter3DTouch);

    return _possibleConstructorReturn(this, (Adapter3DTouch.__proto__ || Object.getPrototypeOf(Adapter3DTouch)).call(this, el, block, options));
  }

  _createClass(Adapter3DTouch, [{
    key: 'bindEvents',
    value: function bindEvents() {
      if (supportsTouchForceChange) {
        this.add('touchforcechange', this.start.bind(this));
        this.add('touchstart', this.support.bind(this, 0));
        this.add('touchend', this._endPress.bind(this));
      } else {
        this.add('touchstart', this.startLegacy.bind(this));
        this.add('touchend', this._endPress.bind(this));
      }
    }
  }, {
    key: 'start',
    value: function start(event) {
      if (event.touches.length > 0) {
        this._startPress(event);
        this.touch = this.selectTouch(event);
        if (this.touch) {
          this._changePress(this.touch.force, event);
        }
      }
    }
  }, {
    key: 'support',
    value: function support(iter, event) {
      var runKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.runKey;

      if (this.isPressed() === false) {
        if (iter <= 6) {
          iter++;
          setTimeout(this.support.bind(this, iter, event, runKey), 10);
        } else {
          this.fail(event, runKey);
        }
      }
    }
  }, {
    key: 'startLegacy',
    value: function startLegacy(event) {
      this.initialForce = event.touches[0].force;
      this.supportLegacy(0, event, this.runKey, this.initialForce);
    }

    // this checks up to 6 times on a touch to see if the touch can read a force value
    // if the force value has changed it means the device supports pressure
    // more info from this issue https://github.com/yamartino/pressure/issues/15

  }, {
    key: 'supportLegacy',
    value: function supportLegacy(iter, event, runKey, force) {
      if (force !== this.initialForce) {
        this._startPress(event);
        this.loopForce(event);
      } else if (iter <= 6) {
        iter++;
        setTimeout(this.supportLegacy.bind(this, iter, event, runKey, force), 10);
      } else {
        this.fail(event, runKey);
      }
    }
  }, {
    key: 'loopForce',
    value: function loopForce(event) {
      if (this.isPressed()) {
        this.touch = this.selectTouch(event);
        setTimeout(this.loopForce.bind(this, event), 10);
        this._changePress(this.touch.force, event);
      }
    }

    // link up the touch point to the correct element, this is to support multitouch

  }, {
    key: 'selectTouch',
    value: function selectTouch(event) {
      if (event.touches.length === 1) {
        return this.returnTouch(event.touches[0], event);
      } else {
        for (var i = 0; i < event.touches.length; i++) {
          // if the target press is on this element
          if (event.touches[i].target === this.el || this.el.contains(event.touches[i].target)) {
            return this.returnTouch(event.touches[i], event);
          }
        }
      }
    }

    // return the touch and run a start or end for deep press

  }, {
    key: 'returnTouch',
    value: function returnTouch(touch, event) {
      this.deepPress(touch.force, event);
      return touch;
    }
  }]);

  return Adapter3DTouch;
}(Adapter);

/*
This adapter is for devices that support pointer events.
*/

var AdapterPointer = function (_Adapter3) {
  _inherits(AdapterPointer, _Adapter3);

  function AdapterPointer(el, block, options) {
    _classCallCheck(this, AdapterPointer);

    return _possibleConstructorReturn(this, (AdapterPointer.__proto__ || Object.getPrototypeOf(AdapterPointer)).call(this, el, block, options));
  }

  _createClass(AdapterPointer, [{
    key: 'bindEvents',
    value: function bindEvents() {
      this.add('pointerdown', this.support.bind(this));
      this.add('pointermove', this.change.bind(this));
      this.add('pointerup', this._endPress.bind(this));
      this.add('pointerleave', this._endPress.bind(this));
    }
  }, {
    key: 'support',
    value: function support(event) {
      if (this.isPressed() === false) {
        if (event.pressure === 0 || event.pressure === 0.5 || event.pressure > 1) {
          this.fail(event, this.runKey);
        } else {
          this._startPress(event);
          this._changePress(event.pressure, event);
        }
      }
    }
  }, {
    key: 'change',
    value: function change(event) {
      if (this.isPressed() && event.pressure > 0 && event.pressure !== 0.5) {
        this._changePress(event.pressure, event);
        this.deepPress(event.pressure, event);
      }
    }
  }]);

  return AdapterPointer;
}(Adapter);

// This class holds the states of the the Pressure config


var Config = {

  // 'false' will make polyfill not run when pressure is not supported and the 'unsupported' method will be called
  polyfill: true,

  // milliseconds it takes to go from 0 to 1 for the polyfill
  polyfillSpeedUp: 1000,

  // milliseconds it takes to go from 1 to 0 for the polyfill
  polyfillSpeedDown: 0,

  // 'true' prevents the selecting of text and images via css properties
  preventSelect: true,

  // 'touch', 'mouse', or 'pointer' will make it run only on that type of device
  only: null,

  // this will get the correct config / option settings for the current pressure check
  get: function get(option, options) {
    return options.hasOwnProperty(option) ? options[option] : this[option];
  },


  // this will set the global configs
  set: function set(options) {
    for (var k in options) {
      if (options.hasOwnProperty(k) && this.hasOwnProperty(k) && k != 'get' && k != 'set') {
        this[k] = options[k];
      }
    }
  }
};

//------------------- Helpers -------------------//

// accepts jQuery object, node list, string selector, then called a setup for each element
var loopPressureElements = function loopPressureElements(selector, closure) {
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

  // if a string is passed in as an element
  if (typeof selector === 'string' || selector instanceof String) {
    var elements = document.querySelectorAll(selector);
    for (var i = 0; i < elements.length; i++) {
      new Element(elements[i], closure, options);
    }
    // if a single element object is passed in
  } else if (isElement(selector)) {
    new Element(selector, closure, options);
    // if a node list is passed in ex. jQuery $() object
  } else {
    for (var i = 0; i < selector.length; i++) {
      new Element(selector[i], closure, options);
    }
  }
};

//Returns true if it is a DOM element
var isElement = function isElement(o) {
  return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === "object" ? o instanceof HTMLElement : //DOM2
  o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string";
};

// the map method allows for interpolating a value from one range of values to another
// example from the Arduino documentation: https://www.arduino.cc/en/Reference/Map
var _map = function _map(x, in_min, in_max, out_min, out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
};

var supportsMouse = false;
var supportsTouch = false;
var supportsPointer = false;
var supportsTouchForce = false;
var supportsTouchForceChange = false;

if (typeof window !== 'undefined') {
  // only attempt to assign these in a browser environment.
  // on the server, this is a no-op, like the rest of the library
  if (typeof Touch !== 'undefined') {
    // In Android, new Touch requires arguments.
    try {
      if (Touch.prototype.hasOwnProperty('force') || 'force' in new Touch()) {
        supportsTouchForce = true;
      }
    } catch (e) {}
  }
  supportsTouch = 'ontouchstart' in window.document && supportsTouchForce;
  supportsMouse = 'onmousemove' in window.document && !supportsTouch;
  supportsPointer = 'onpointermove' in window.document;
  supportsTouchForceChange = 'ontouchforcechange' in window.document;
}
return Pressure;
}));

},{}],4:[function(require,module,exports){
/*
会飘的手
*/

var { Plot } = require("../Plot.js");
var { Point } = require("../Point")
/**
 * @type {HTMLCanvasElement}
 */
var canvasDom = document.querySelector("#myCanvas");
var plot = new Plot(canvasDom)
var context = canvasDom.getContext("2d");
canvasDom.width = document.body.clientWidth;;
canvasDom.height = document.body.clientHeight;

var list = [];
var i00 = 0;


var Pressure = require('pressure');

Pressure.config({
  polyfill: false,
  polyfillSpeedDown: 0,
  preventDefault: true,
  only: null
});
var time00 = 0;

Pressure.set('#myCanvas', {
  change: function(force){

		list.push({ y: force * canvasDom.height, x: i00++ })

		if(time00%100==0){
			plot.drawList(list);
		}
  }
});

// 测试  browserify -o pack.js ./pointEvent.jsbrowserify -o
},{"../Plot.js":1,"../Point":2,"pressure":3}]},{},[4]);
